package com.huike.clues.service.impl;


import com.huike.clues.domain.TbClue;
import com.huike.clues.domain.vo.ClueTrackRecordVo;
import com.huike.clues.mapper.TbClueMapper;
import com.huike.clues.mapper.TbClueTrackRecordMapper;
import com.huike.clues.service.ITbClueTrackRecordService;
import com.huike.common.utils.DateUtils;
import com.huike.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 线索跟进记录Service业务层处理
 */
@Service
public class TbClueTrackRecordServiceImpl implements ITbClueTrackRecordService {

    @Autowired
    private TbClueMapper clueMapper;
    @Autowired
    private TbClueTrackRecordMapper recordMapper;

    /**
     * 新增线索跟进记录
     */

    @Override
    public void add(ClueTrackRecordVo clueTrackRecordVo) {
        String username = SecurityUtils.getUsername();
        clueTrackRecordVo.setCreateBy(username);
        clueTrackRecordVo.setCreateTime(DateUtils.getNowDate());
        recordMapper.add(clueTrackRecordVo);
        //修改线索表的数据
        TbClue tbClue = new TbClue();
        tbClue.setAge(clueTrackRecordVo.getAge());
        tbClue.setQq(clueTrackRecordVo.getQq());
        tbClue.setWeixin(clueTrackRecordVo.getWeixin());
        tbClue.setSex(clueTrackRecordVo.getSex());
        tbClue.setId(clueTrackRecordVo.getClueId());
        tbClue.setName(clueTrackRecordVo.getName());
        clueMapper.updateTbClue(tbClue);
    }

    /**
     * 查询线索跟进记录列表
     */
    @Override
    public List<ClueTrackRecordVo> list(Long clueId) {
        return recordMapper.list(clueId);
    }

}
